package org.cqepc.project.reform.utils.util;

import java.text.DecimalFormat;

public class SerialNoGenerateUtil {

    public static String getSerialNo(String code) throws Exception {
        String roundCode = "01";
        if (code != null && !code.isEmpty()) {
            int intCode = Integer.parseInt((code)) + 1;
            if (intCode < 9999) {
                roundCode = String.format(String.valueOf(intCode));
            } else {
                throw new Exception("轮次编号达到最大");
            }
        }

        // 编号前面补0
        DecimalFormat decimalFormat = new DecimalFormat("00");
        String newCode = decimalFormat.format(Integer.parseInt(roundCode));
        return newCode;
    }

}
